using Services;

public class SubController
{
    protected Player player;
    protected GameManager gameManager;
    protected GlobalGameCycle gameCycle;

    protected bool active;
    public bool Active
    {
        get => active;
        set
        {
            if (value != active)
            {
                if (value)
                {
                    OnEnable();
                    gameCycle.AttachToGameCycle(EInvokeMode.Update, Update);
                }
                else
                {
                    OnDisable();
                    gameCycle.RemoveFromGameCycle(EInvokeMode.Update, Update);
                }
                active = value;
            }
        }
    }

    public SubController()
    {
        gameCycle = ServiceLocator.Get<GlobalGameCycle>();
        player = ServiceLocator.Get<ActionController>().player;
        gameManager = ServiceLocator.Get<GameManager>();
    }

    public virtual void Update() { }

    public virtual void OnEnable() { }

    public virtual void OnDisable() { }
}
